<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let numArr = [1, 2, 34, 44, 5, 1, 2, 33, 1, 1, 556, 45, 44];
      //传入从numArr，和数据返回数据在数组中出现了几次
      function count(arr, index) {
        let a = arr.filter((v) => v == index);
        // console.log(a);
        // console.log(a.length);
        return console.log(index + "出现了" + a.length + "次");
      }

      count(numArr, 44);
      count(numArr, 1);
      // console.log('count(numArr,44)');
    </script>
  </body>
</html>
